<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        nav {
            width: 200px;
            height: 200px;
            background: black;
            color: white;
        }
    </style>
</head>

<body>
    <p>属性名<input type="text"></p>
    <p>属性值<input type="text"></p>
    <div>
        <button class="qd">确定</button>
        <button class="cz">重置</button>
    </div>
    <nav>
        在上方输入框输入"属性名"及"属性值"，点击确定按钮查看效果。
    </nav>
</body>

</html>
<script>
    let qd = document.querySelector(".qd")
    let cz = document.querySelector(".cz")
    let inp = document.querySelectorAll("input")
    let nav = document.querySelector("nav")
    qd.onclick = function () {
        let val1 = inp[0].value
        let val2 = inp[1].value
        console.log("11", inp[0].value);
        console.log("22", inp[1].value);
        nav.style[inp[0].value] = inp[1].value
    }
</script>